#include <stdio.h>
#include <iostream>
#include "networking.h"
using namespace std;

main ()
{
  cout << "Should I be a server (0) or a client (1)? ";
  bool client;
  cin >> client;
  if (client)
    {
      
      const char* message;
      char* reply;
      string temp, temp2;
      network gameClient;
      cout << "Enter ip: ";
      cin >> temp;
      char* ip = new char[temp.size() + 1];
      copy(temp.begin(), temp.end(), ip);
      ip[temp.size()] = '\0';
      for(int i=1; i<3; i++){
      cout << "Enter message: ";
      cin >> temp2;
      message = temp2.c_str();
      reply = gameClient.runClient(ip, message);
      cout << reply << endl;
      }
      delete[] ip;
      
    }


  else
    {
      for(int i = 1; i < 3; i++)
	{      
      const char* message;
      char* reply;
      string temp;
      network gameServer;
      cout << "Enter message: ";
      cin >> temp;
      message = temp.c_str();
      reply = gameServer.runServer(message);
      cout << reply << endl; 
	}
    }

  return 0;
}
